package think.thread.c07.countdownlatch;

import java.util.concurrent.CountDownLatch;

public class WaitTask implements Runnable{
	
	private static int count=0;
	private final int id=count++;

	private CountDownLatch latch;
	
	public WaitTask(CountDownLatch latch){
		this.latch=latch;
	}
	
	public void run() {
		try {
			latch.await();
			System.out.println("Lathch barrier passed for "+this);
		} catch (Exception e) {
		}
	}
	
	public String toString(){
		return String.format("WaitingTask %1$-3d ", id);
	}

}
